using SmartSoft.DAL;
using System.Web.Services;
using System;
using System.Data;
using System.Data.SqlClient;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
public class WSSSInvoiceLibDataAccess : System.Web.Services.WebService
{
    private SSInvoiceLibDataAccess objDataAccess = new SSInvoiceLibDataAccess();
    public WSSSInvoiceLibDataAccess()
    {
    }


    [WebMethod]
    public string CtVAT_So_Ct0_List(object ps_MasterKey)
    {
        object[] arr = Validator.Validate(ps_MasterKey);
        return objDataAccess.CtVAT_So_Ct0_List(arr[0]);
    }

    [WebMethod]
    public int CtVAT_Status_Get(object ps_Ma_Nvu, object ps_MasterKey)
    {
        object[] arr = Validator.Validate(ps_Ma_Nvu, ps_MasterKey);
        return objDataAccess.CtVAT_Status_Get(arr[0], arr[1]);
    }


    [WebMethod(MessageName = "NoneParams", Description = "", EnableSession = true)]
    public decimal ExchangeRate(object ps_Ma_Tte)
    {
        object[] arr = Validator.Validate(ps_Ma_Tte);
        return objDataAccess.ExchangeRate(arr[0]);
    }

    [WebMethod(MessageName = "OneParams", Description = "", EnableSession = true)]
    public decimal ExchangeRate(object ps_Ma_Tte, ref bool pb_ExchangeType)
    {
        object[] arr = Validator.Validate(ps_Ma_Tte);
        return objDataAccess.ExchangeRate(arr[0], ref pb_ExchangeType);
    }

    [WebMethod]
    public void GetBankAccount(object ps_MasterKey, ref object ps_Ten_Dvi_A, ref object ps_Tk_NH_A, ref object ps_Ten_NH_A, ref object ps_Ten_TP_A, ref object ps_Ten_Dvi_B, ref object ps_Tk_NH_B, ref object ps_Ten_NH_B, ref object ps_Ten_TP_B)
    {
        object[] arr = Validator.Validate(ps_MasterKey,  ps_Ten_Dvi_A,  ps_Tk_NH_A,  ps_Ten_NH_A,  ps_Ten_TP_A,  ps_Ten_Dvi_B,  ps_Tk_NH_B,  ps_Ten_NH_B,  ps_Ten_TP_B);
        objDataAccess.GetBankAccount(ps_MasterKey, ref ps_Ten_Dvi_A, ref ps_Tk_NH_A, ref ps_Ten_NH_A, ref ps_Ten_TP_A, ref ps_Ten_Dvi_B, ref ps_Tk_NH_B, ref ps_Ten_NH_B, ref ps_Ten_TP_B);
    }

    [WebMethod]
    public DataTable GetDetailHistoryTable(string ps_Ma_Nvu, object pi_HistoryID)
    {
        object[] arr = Validator.Validate(pi_HistoryID);
        return objDataAccess.GetDetailHistoryTable(ps_Ma_Nvu, arr[0]);
    }

    [WebMethod(MessageName = "GetHistoryTable1", Description = "", EnableSession = true)]
    public DataTable GetHistoryTable(object ps_InvoiceOrder)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder);
        return objDataAccess.GetHistoryTable(arr[0]);
    }

    [WebMethod(MessageName = "GetHistoryTable2", Description = "", EnableSession = true)]
    public DataTable GetHistoryTable(string ps_Subsidiary, string ps_InvoiceCode, object pd_Ngay_Ct1, object pd_Ngay_Ct2)
    {
        object[] arr = Validator.Validate(pd_Ngay_Ct1, pd_Ngay_Ct2);
        return objDataAccess.GetHistoryTable(ps_Subsidiary, ps_InvoiceCode, arr[0], arr[1]);
    }

    [WebMethod]
    public DataTable GetInvoiceRow(string ps_InvoiceCode)
    {
        return SSDataAccess.ConvertRowToTable(objDataAccess.GetInvoiceRow(ps_InvoiceCode));
    }

    [WebMethod]
    public DataTable GetInvoices(string ps_InvoiceCode)
    {

        return objDataAccess.GetInvoices(ps_InvoiceCode);
    }

    [WebMethod]
    public DataTable GetMasterHistoryDataRow(string ps_Ma_Nvu, object pi_HistoryID)
    {
        object[] arr = Validator.Validate(pi_HistoryID);
        return SSDataAccess.ConvertRowToTable(objDataAccess.GetMasterHistoryDataRow(ps_Ma_Nvu, arr[0]));
    }

    [WebMethod]
    public DataTable GetMasterHistoryTable(string ps_Ma_Nvu, object ps_InvoiceOrder)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder);
        return objDataAccess.GetMasterHistoryTable(ps_Ma_Nvu, arr[0]);
    }

    [WebMethod]
    public DataTable GetPaymentDetailTable(string ps_Subsidiary, object ps_InvoiceOrder, object ps_Ma_Bp, object ps_Ma_Hd, object ps_Ma_Dt, object ps_No_Co, object ps_Tk, object ps_Ma_Tte, object pd_Han_Tt, object pd_Ngay_Ct)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder, ps_Ma_Bp, ps_Ma_Hd, ps_Ma_Dt, ps_No_Co, ps_Tk, ps_Ma_Tte, pd_Han_Tt, pd_Ngay_Ct);
        return objDataAccess.GetPaymentDetailTable(ps_Subsidiary, arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]);
    }

    [WebMethod]
    public DataTable GetPaymentMasterTable(object ps_InvoiceOrder)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder);
        return objDataAccess.GetPaymentMasterTable(arr[0]);
    }

    [WebMethod]
    public int InvoiceStatus(string ps_Subsidiary, string ps_Ma_Nvu, string ps_UserName, object ps_InvoiceOrder)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder);
        return objDataAccess.InvoiceStatus(ps_Subsidiary, ps_Ma_Nvu, ps_UserName, arr[0]);
    }

    [WebMethod]
    public void MakeAmountWarningMessage(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Tk, ref string ps_Ten_Tk, ref string ps_Ten_Tk_E, object ps_Ma_Dt, ref string ps_No_Co, ref string ps_Ten_Dt, ref string ps_Ten_Dt_E, string ps_SQLCmd, ref decimal pi_Du_No, ref decimal pi_Du_Co, ref decimal pi_Tien_Lmt)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Tk, ps_Ma_Dt);
        objDataAccess.MakeAmountWarningMessage(ps_Subsidiary, arr[0], arr[1], arr[2], ref ps_Ten_Tk, ref ps_Ten_Tk_E, arr[3], ref ps_No_Co, ref ps_Ten_Dt, ref ps_Ten_Dt_E, ps_SQLCmd, ref pi_Du_No, ref pi_Du_Co, ref pi_Tien_Lmt);
    }

    [WebMethod]
    public void MakeLotQtyWarningMessage(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, ref string ps_Ten_Kho, ref string ps_Ten_Kho_E, object ps_Ma_Vt, ref string ps_Ten_Vt, ref string ps_Ten_Vt_E, ref string ps_Dvt, ref string ps_Dvt_E, object ps_Lo_Hang, string ps_SQLCmd, ref decimal pi_Ton_Kho)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Vt, ps_Lo_Hang);
        objDataAccess.MakeLotQtyWarningMessage(ps_Subsidiary, arr[0], arr[1], arr[2], ref ps_Ten_Kho, ref ps_Ten_Kho_E, arr[3], ref ps_Ten_Vt, ref ps_Ten_Vt_E, ref ps_Dvt, ref ps_Dvt_E, arr[4], ps_SQLCmd, ref pi_Ton_Kho);
    }

    [WebMethod]
    public DataTable MakeLotQuantity(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, object ps_Ma_Vt, object ps_Lo_Hang, string ps_SQLCmd, int pi_Max_Rows)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Vt, ps_Lo_Hang);
        return objDataAccess.MakeLotQuantity(ps_Subsidiary, arr[0], arr[1], arr[2], arr[3], arr[4], ps_SQLCmd, pi_Max_Rows);
    }

    [WebMethod]
    public DataTable MakeOutLotQuantity(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, object ps_Ma_Vt, object ps_Lo_Hang, string ps_SQLCmd, int pi_Max_Rows)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Vt, ps_Lo_Hang);
        return objDataAccess.MakeOutLotQuantity(ps_Subsidiary, arr[0], arr[1], arr[2], arr[3], arr[4], ps_SQLCmd, pi_Max_Rows);
    }

    [WebMethod]
    public void MakeQtyWarningMessage(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, ref string ps_Ten_Kho, ref string ps_Ten_Kho_E, object ps_Ma_Vt, ref string ps_Ten_Vt, ref string ps_Ten_Vt_E, ref string ps_Dvt, ref string ps_Dvt_E, string ps_SQLCmd, ref decimal pi_Ton_Kho, ref decimal pi_SL_Ton_Min, ref decimal pi_SL_Ton_Max)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Vt);
        objDataAccess.MakeQtyWarningMessage(ps_Subsidiary, arr[0], arr[1], arr[2], ref ps_Ten_Kho, ref ps_Ten_Kho_E, arr[3], ref ps_Ten_Vt, ref ps_Ten_Vt_E, ref ps_Dvt, ref ps_Dvt_E, ps_SQLCmd, ref pi_Ton_Kho, ref pi_SL_Ton_Min, ref pi_SL_Ton_Max);
    }

    [WebMethod(MessageName = "MakeStockLotQuantity1", Description = "", EnableSession = true)]
    public DataTable MakeStockLotQuantity(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, object ps_Ma_Vt, string ps_SQLCmd)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Vt);
        return objDataAccess.MakeStockLotQuantity(ps_Subsidiary, arr[0], arr[1], arr[2], arr[3], ps_SQLCmd);
    }

    [WebMethod(MessageName = "MakeStockLotQuantity2", Description = "", EnableSession = true)]
    public DataTable MakeStockLotQuantity(string ps_Subsidiary, object ps_MasterKey, object pd_Ngay_Ct, object ps_Ma_Kho, object ps_Ma_Ke, object ps_Ma_Vt, object ps_Lo_Hang, string ps_SQLCmd, int pi_Max_Rows)
    {
        object[] arr = Validator.Validate(ps_MasterKey, pd_Ngay_Ct, ps_Ma_Kho, ps_Ma_Ke, ps_Ma_Vt, ps_Lo_Hang);
        return objDataAccess.MakeStockLotQuantity(ps_Subsidiary, arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], ps_SQLCmd, pi_Max_Rows);
    }

    [WebMethod]
    public DataTable RefTable_Get(object ps_MasterKey)
    {
        object[] arr = Validator.Validate(ps_MasterKey);
        return objDataAccess.RefTable_Get(arr[0]);
    }

    [WebMethod]
    public void ResetInvoiceNumber(string ps_StoredProcedure, string ps_Subsidiary, string ps_InvoiceCode, object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_So_Ct0, object pi_So_Ct1)
    {
        object[] arr = Validator.Validate(pd_Ngay_Ct1, pd_Ngay_Ct2, ps_So_Ct0, pi_So_Ct1);
        objDataAccess.ResetInvoiceNumber(ps_StoredProcedure, ps_Subsidiary, ps_InvoiceCode, arr[0], arr[1], arr[2], arr[3]);
    }

    [WebMethod]
    public void Restore(string ps_Ma_Nvu, string ps_UserName, object ps_InvoiceOrder, object pi_HistoryID)
    {
        object[] arr = Validator.Validate(ps_InvoiceOrder, pi_HistoryID);
        objDataAccess.Restore(ps_Ma_Nvu, ps_UserName, arr[0], arr[1]);
    }

    [WebMethod]
    public bool Save(string ps_Ma_Nvu, DataTable po_MasterDataRow, DataTable po_DetailTable)
    {

        return objDataAccess.Save(ps_Ma_Nvu, po_MasterDataRow.Rows[0], po_DetailTable);
    }

    [WebMethod]
    public void SaveBankAccount(object ps_MasterKey, object ps_Ten_Dvi_A, object ps_Tk_NH_A, object ps_Ten_NH_A, object ps_Ten_TP_A, object ps_Ten_Dvi_B, object ps_Tk_NH_B, object ps_Ten_NH_B, object ps_Ten_TP_B)
    {
        object[] arr = Validator.Validate(ps_MasterKey, ps_Ten_Dvi_A, ps_Tk_NH_A, ps_Ten_NH_A, ps_Ten_TP_A, ps_Ten_Dvi_B, ps_Tk_NH_B, ps_Ten_NH_B, ps_Ten_TP_B);
        objDataAccess.SaveBankAccount(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8]);
    }
}